import { Entity, Column, ManyToMany } from "typeorm";
import { Base } from "@/entities.base/base.entity";
import { Role } from "../role.entity";

@Entity({ comment: '权限表', name: 'sys_permission' })
export class Permission extends Base{

    /** 权限名称 */
    @Column({
        comment: '权限名称',
        length: 50,
        unique: true
    })
    name: string;

    /** 权限代码 */
    @Column({
        comment: '权限代码',
        length: 100,
        unique: true
    })
    code: string;

    /** 权限描述 */
    @Column({
        comment: '权限描述',
        length: 200,
        nullable: true
    })
    description: string;

    /** 所属角色 */
    @ManyToMany(() => Role, role => role.permissions)
    roles: Role[];
}
